[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See
Storage Client Library for the latest version.]
Executes the query with the retry policy specified on the
CloudTableQuery object.
Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Usage
Visual Basic |
---|
Dim instance As CloudTableQuery(Of TElement)
Dim returnValue As IEnumerable(Of TElement)
returnValue = instance.Execute |
Syntax
Visual Basic |
---|
Public Function Execute As IEnumerable(Of TElement) |
C# |
---|
public IEnumerable<TElement> Execute () |
C++ |
---|
public:
IEnumerable<TElement>^ Execute () |
Return Value
Type: System.Collections.Generic.IEnumerable
The query result.
Example
The following code example creates and executes a query against a table.
| Copy Code |
---|
public static void ExecuteQuery(CloudStorageAccount storageAccount)
{
// Create the service context.
TableServiceContext context = new TableServiceContext(storageAccount.TableEndpoint.ToString(),
storageAccount.Credentials);
// Execute the query and write out some data.
foreach (var entity in context.CreateQuery<ProductEntity>("Products").AsTableServiceQuery<ProductEntity>().Execute())
{
Console.WriteLine("Product name: {0} Price: {1}", entity.ProductName, entity.Price);
}
Console.WriteLine();
// Execute the query with criteria that simulates a LIKE clause.
foreach (var entity in context.CreateQuery<ProductEntity>("Products")
.Where(e => (e.ProductName.CompareTo("J") >= 0 && e.ProductName.CompareTo("K") < 0))
.AsTableServiceQuery<ProductEntity>().Execute())
{
Console.WriteLine("Product name: {0} Price: {1}", entity.ProductName, entity.Price);
}
}
// Define a class that represents an entity.
class ProductEntity : TableServiceEntity
{
public ProductEntity()
{
}
public string ProductName { get; set; }
public string Category { get; set; }
public double Price { get; set; }
public bool InStock { get; set; }
public DateTime DateAdded { get; set; }
public Int32 Quantity { get; set; }
}
|
Remarks
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms
Change History
See Also